<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ProductComment.jsp' starting page</title>
    <script type="text/javascript">
function rate(obj,oEvent){
		var imgSrc = 'images/icon_star_1.gif';
		var imgSrc_2 = 'images/icon_star_2.gif';
			
		if(obj.rateFlag) return;
		var e = oEvent || window.event;
		var target = e.target || e.srcElement;
		var imgArray = document.getElementsByName("star");
		for(var i=0;i<imgArray.length;i++){
		   imgArray[i]._num = i;
		   imgArray[i].onclick=function(){
		    if(obj.rateFlag) return;
		    //alert(this._num+1);
		    var num=this._num+1;
			document.getElementById("s").innerHTML=num+"<input type='hidden' name='score' value="+num+">";
		 var inputid=this.parentNode.previousSibling
		 inputid.value=this._num+1;
		   }
		}
		
		
		if(target.tagName=="IMG"){
		   for(var j=0;j<imgArray.length;j++){
		    if(j<=target._num){
		     imgArray[j].src=imgSrc_2;
		    } else {
		     imgArray[j].src=imgSrc;
		    }
		 target.parentNode.onmouseout=function(){
		 var imgnum=parseInt(target.parentNode.previousSibling.value);
		  for(n=0;n<imgArray.length;n++){
		   imgArray[n].src=imgSrc;
		  }
		  for(n=0;n<imgnum;n++){
		   imgArray[n].src=imgSrc_2;
		  }
		 }
		   }
		} else {
		  return false;
		}
}
</script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  
  <%String name =(String)session.getAttribute("userLoginName"); 
  	if(name!=null){
  		%>
  		你还没有登录<a href="index.jsp">返回</a>
  		<%
  	}else{
  %>
  <%if((String)request.getParameter("id")==null) {
	  %>
	  你还没有选择商品<a href="product.jsp">返回</a>
	  <%
  }else{
	  %>  产品<%=(String)request.getParameter("id") %>的评论
	      <form action="CommentServlet?id=<%=(String)request.getParameter("id") %>" method="post">
<table width="100%" border="1" align="center">
  <tr>
    <td width="42%" height="106">用户名：<%=name %></td>
    <td width="58%">匿名评论<input type="checkbox" name="noname" value="0" /></td>
  </tr>
  <tr>
    <td height="106" colspan="2">评分等级<p onmouseover="rate(this,event)">
<img name="star" src="images/icon_star_1.gif" title="很烂"><img name="star" src="images/icon_star_1.gif" title="一般"><img name="star" src="images/icon_star_1.gif" title="还好"><img name="star" src="images/icon_star_1.gif" title="较好"><img name="star" src="images/icon_star_1.gif" title="很好">
<span id="s"></span></p></td>
  </tr>
  <tr>
    <td height="119" colspan="2">评论
    <textarea name="content" rows=5 cols=60 >
</textarea>
</td>
  </tr>
</table>
<input type="submit" value="提交" />
</form>
	  <%
  }
}
  	%>
  </body>
</html>
